<?php
// 接口API**********************
//username 用户名
// 接口API**********************
//获取传入的参数
$ways = $_REQUEST['ways'];
$mid = $_REQUEST['mid'];
$id = $_REQUEST['id'];
$shop = $_REQUEST['shop'];
$page = $_REQUEST['page'];
$size = $_REQUEST['size'];
//建立数据库连接
$link = mysqli_connect('localhost','root','123456','twoStage');
//判断连接成功与否
if(!$link){
    die('连接失败'.mysqli_connect_error());
};
//设置编码
mysqli_set_charset($link,'utf8');

if($ways == "all"){
//sql语句，查找所有数据
$search = "select * from goods";
}else if($ways == "bigNav1"){
$search = "select * from goods where bigNav='卧室'";
}else if($ways == "bigNav2"){
$search = "select * from goods where bigNav='客厅'";
}else if($ways == "bigNav3"){
$search = "select * from goods where bigNav='餐厅'";
}else if($ways == "bigNav4"){
$search = "select * from goods where bigNav='书房'";
}else if($ways == "bigNav5"){
$search = "select * from goods where bigNav='儿童房'";
}else if($ways == "bigNav6"){
$search = "select * from goods where bigNav='办公家具'";
}else if($ways == "midNav"){
$search = "select * from goods where midNav='$mid'";
}else if($ways == 'detail'){
$search = "select * from goods where id='$id'";
}else if($ways == 'shop'){
$search = "select * from goods where shop='$shop'";
}else if($ways == "bigNav1-1"){
$search = "select * from goods where midNav='卧室'";
}else if($ways == "smaNav"){
$search = "select * from goods where smaNav='$mid'";
}

























//执行sql语句
$searchDo = mysqli_query($link,$search);

//解析数据
$rows = mysqli_fetch_all($searchDo,1);

$length1 = count($rows);
if($length1>0){
        echo json_encode($rows,JSON_UNESCAPED_UNICODE); 
}else{
    echo $length1;
}


//关闭数据库连接
mysqli_close($link);
?>